package com.ruoyi.busi.guide.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.core.domain.R;
import com.ruoyi.busi.guide.domain.Feedback;
import com.ruoyi.busi.guide.service.IFeedbackService;

/**
 * 导师评价Controller
 */
@RestController
@RequestMapping("/busi/guide/feedback")
public class FeedbackController extends BaseController {
    @Autowired
    private IFeedbackService feedbackService;

    /**
     * 根据导师ID获取评价列表
     */
    @GetMapping("/mentor/{mentorId}")
    public R listByMentorId(@PathVariable Long mentorId) {
        return R.ok(feedbackService.selectByMentorId(mentorId));
    }

    /**
     * 根据评分范围获取评价列表
     */
    @GetMapping("/rating")
    public R listByRatingRange(
        @RequestParam(required = false, defaultValue = "1") Integer minRating,
        @RequestParam(required = false, defaultValue = "5") Integer maxRating) {
        return R.ok(feedbackService.selectByRatingRange(minRating, maxRating));
    }

    /**
     * 新增评价
     */
    @PostMapping
    public R add(@RequestBody Feedback feedback) {
        return R.ok(feedbackService.save(feedback));
    }

    /**
     * 删除评价
     */
    @DeleteMapping("/{feedbackIds}")
    public R remove(@PathVariable List<Long> feedbackIds) {
        return R.ok(feedbackService.deleteFeedbackByIds(feedbackIds));
    }
}
